package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.DeptInfoEntity;
import com.uchiha.nova.core.model.vo.DeptInfoVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.IDeptInfoService;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 部门信息 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class DeptInfoWrapper extends BaseEntityWrapper<DeptInfoEntity, DeptInfoVO>  {
  
  IDeptInfoService deptInfoService = SpringUtil.getBean(IDeptInfoService.class);
  
	public static DeptInfoWrapper build() {
		return new DeptInfoWrapper();
 	}

	@Override
	public DeptInfoVO entityVO(DeptInfoEntity deptInfoEntity) {
		DeptInfoVO deptInfoVO = new DeptInfoVO();
		BeanUtil.copyProperties(deptInfoEntity, deptInfoVO);

		return deptInfoVO;
	}
	public List<DeptInfoVO> listVO(List<DeptInfoEntity> list) {
		List<DeptInfoVO> collect = list.stream().map(item -> {
            DeptInfoVO deptInfoVO = new DeptInfoVO();
		    BeanUtil.copyProperties(item, deptInfoVO);			
			return deptInfoVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<DeptInfoVO> pageVO(IPage<DeptInfoEntity> pages) {
		IPage<DeptInfoVO> page = pages.convert(item->{
            DeptInfoVO deptInfoVO = new DeptInfoVO();
		    BeanUtil.copyProperties(item, deptInfoVO);			
			return deptInfoVO;
		});
		return page;
	}
}
